/*
 *  Copyright (C) 2011 glauco
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.swing.components.focusManager;

import java.awt.Component;
import java.awt.Container;
import java.util.List;

/**
 * Evento de troca de focus entre componentes de um mesmo container.
 *
 * @author glauco
 */
public class FocusTraversalEvent {

    /**
     * Component com o focus anterior.
     */
    private Component oldComponent;

    /**
     * Novo component com o focus.
     */
    private Component newComponent;

    /**
     * Container do FocusTraversalPolicy dos componentes.
     */
    private Container container;

    /**
     * Componentes atravessados pela mudança de focus.
     */
    private List<Component> traversedComponents;

    /**
     * Componentes percorridos para baixo.
     */
    private boolean traversedToDown;

    /**
     * Contrutor, deve-se informar todos os campos.
     */
    public FocusTraversalEvent(
            Component oldComponent,
            Component newComponent,
            Container container,
            List<Component> traversedComponents,
            boolean traversedToDown) {

        this.oldComponent = oldComponent;
        this.newComponent = newComponent;
        this.container = container;
        this.traversedComponents = traversedComponents;
        this.traversedToDown = traversedToDown;
    }

    /**
     * Pega Container do FocusTraversalPolicy dos componentes.
     */
    public Container getContainer() {
        return container;
    }

    /**
     * Novo component com o focus.
     */
    public Component getNewComponent() {
        return newComponent;
    }

    /**
     * Component com o focus anterior.
     */
    public Component getOldComponent() {
        return oldComponent;
    }

    /**
     * Componentes atravessados pela mudança de focus.
     */
    public List<Component> getTraversedComponents() {
        return traversedComponents;
    }

    /**
     * Componentes percorridos para baixo.
     */
    public boolean isTraversedToDown(){
        return traversedToDown;
    }

    @Override
    public String toString() {
        return "FocusTraversalEvent{ oldComponent = " + oldComponent.getName() +
                " newComponent = " + newComponent.getName() +
                " traversedToDown = " + traversedToDown + '}';
    }
}
